package com.cdwang.notificationmodule;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.NotificationCompat;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Intent;
import android.graphics.BitmapFactory;
import android.os.Build;
import android.os.Bundle;
import android.view.View;

import com.cdwang.notification_module.NotificationUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.listener.OnItemClickListener;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {
    private NotificationAdapter notificationAdapter;
    private LinearLayoutManager manager;
    private RecyclerView rv;
    private String bigText="A notification is a message that Android displays outside your app's UI to provide the user with reminders, communication from other people, or other timely information from your app. Users can tap the notification to open your app or take an action directly from the notification.";
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
//        item_notification
        rv=findViewById(R.id.rv);
        List<String> list=new ArrayList<>();
        list.add("普通通知");
        list.add("重要通知");
        list.add("大文本通知");
        list.add("大图片通知");
        manager=new LinearLayoutManager(this);
        notificationAdapter=new NotificationAdapter(R.layout.item_notification,list);
        rv.setLayoutManager(manager);
        rv.setAdapter(notificationAdapter);
        notificationAdapter.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(@NonNull BaseQuickAdapter<?, ?> adapter, @NonNull View view, int position) {
                String s = notificationAdapter.getData().get(position);
                switch (s){
                    case "普通通知":
//                        createNotificationForNormal();
                        NotificationUtils.createNotificationForNormal(MainActivity.this
                                ,MainActivity.class,R.mipmap.icon_user,"请输入标题","请输入内容");
                        break;
                    case "重要通知":
//                        createNotificationForHigh();
                        NotificationUtils.createNotificationForHigh(MainActivity.this
                                ,null,R.mipmap.icon_user,"请是一条重要标题","请是一条重要内容");
                        break;
                    case "大文本通知":
                        NotificationUtils.createNotificationForBigText(MainActivity.this
                                ,R.mipmap.icon_user,"请是一条重要标题",bigText);
                        break;
                    case "大图片通知":
                        NotificationUtils.createNotificationForBigImage(MainActivity.this
                                ,R.mipmap.icon_user,R.mipmap.icon_user,"大图片通知","有美女，展开看看");
                        break;
                    default:
                        break;
                }

            }
        });
    }




}

class NotificationAdapter extends BaseQuickAdapter<String, BaseViewHolder> {

    public NotificationAdapter(int layoutResId, @Nullable List<String> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(@NotNull BaseViewHolder holder, String s) {
      holder.setText(R.id.tv,s);
    }
}